package com.winner.strategy_pattern.phoneplan;


import org.springframework.stereotype.Service;

@Service
public class IceCreamServiceImpl implements PhonePlanStrategy {

    @Override
    public double doOperation(int talkTime, int flow) {
        int exceedTalkTime = talkTime <= 100 ? 0 : (talkTime - 100);
        int exceedFlow = flow <= 10 * 1024 ? 0 : (flow - 10 * 1024);
        double result = 50 + 0.1 * exceedTalkTime + 0.1 * exceedFlow;
        System.out.println("使用冰淇淋套餐资费为：" + result + "元");
        return result;
    }

    @Override
    public void afterPropertiesSet() throws Exception {
        PhonePlanFactory.register("ICE_CREAM", this);
    }
}
